import { defineComponent, h, computed, ref } from "@vue/runtime-core";
import StartPage from "./page/StartPage";
import GamePage from "./page/GamePage";
import EndPage from "./page/EndPage";

export default defineComponent({
  setup(props, ctx) {
    let currentPage = ref("StartPage");

    let currentComponent = computed(() => {
      if (currentPage.value === "StartPage") {
        return StartPage;
      } else if (currentPage.value === "GamePage") {
        return GamePage;
      } else {
        return EndPage;
      }
    });

    return { currentPage, currentComponent };
  },
  render(ctx) {
    // 创建vnode changePage
    return h("Container", [
      h(ctx.currentComponent, {
        onChangePage(page) {
          ctx.currentPage = page;
        },
      }),
    ]);
  },
});
